package com.sdx.console.content.service;

import java.util.List;

import org.beetl.sql.core.engine.PageQuery;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ibeetl.admin.core.util.PlatformException;

import com.sdx.console.content.dao.EbookChapterDao;
import com.sdx.console.content.entity.EbookChapter;
import com.ibeetl.admin.core.service.BaseService;

/**
 * 电子书章节 Service
 */

@Service
@Transactional
public class EbookChapterService extends BaseService<EbookChapter>{

    @Resource
	private EbookChapterDao ebookChapterDao;

    public PageQuery<EbookChapter>queryByCondition(PageQuery query){
        PageQuery ret =  ebookChapterDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelEbookChapter(List<String> ids){
        try {
            ebookChapterDao.batchDelEbookChapterByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除电子书章节失败", e);
        }
    }

	public List<EbookChapter> all() {
		return ebookChapterDao.all();
		}

	public List<EbookChapter> listChapterByBookId(Integer bookId){
        return ebookChapterDao.listChapterByBookId(bookId);
    }
}